<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../vue.js"></script>
    <script src="../vue-router.js"></script>
</head>

<body>
    <div id="app">
        <router-link to="/user">User</router-link>
        <router-link to="/regeister">Regeister</router-link>
        <router-view></router-view>
    </div>
    <script>
        const User = {
            template: '<h1>User</h1>'
        }
        const Regeister = {
            template: `<div>
            <h1>Register 组件</h1>
            <hr/>
            <router-link to="/regeister/tab1">tab1</router-link>
            <router-link to="/regeister/tab2">tab2</router-link>
            <router-view />
            </div>`
        }
        const Tab1 = {
            template: '<h3>tab1 子组件</h3>'
        }
        const Tab2 = {
            template: '<h3>tab2 子组件</h3>'
        }
        const router = new VueRouter({
            routes: [{
                path: '/',
                redirect: '/user'
            }, {
                path: '/user',
                component: User
            }, {
                path: '/regeister',
                component: Regeister,
                children: [{
                    path: '/regeister/tab1',
                    component: Tab1
                }, {
                    path: '/regeister/tab2',
                    component: Tab2
                }]
            }, ]
        })
        var vm = new Vue({
            el: '#app',
            data: {

            },
            router: router
        })
    </script>
</body>

</html>